/*******************************************************************************
 * Package: com.hngtrust.iir.company.controller
 * Type:    DictController
 * Date:    2020-11-30 10:59
 *
 * Copyright (c) 2020 HUANENG GUICHENG TRUST CORP.,LTD All Rights Reserved.
 *
 * You may not use this file except in compliance with the License.
 *******************************************************************************/
package com.hngtrust.iir.company.controller;

import com.hngtrust.framework.bind.ResponseInfo;
import com.hngtrust.framework.page.PageResult;
import com.hngtrust.iir.company.controller.vo.AiCompanyReqVO;
import com.hngtrust.iir.company.controller.vo.CompChangeRespVO;
import com.hngtrust.iir.company.controller.vo.ListChangeRespVO;
import com.hngtrust.iir.company.controller.vo.ListCompanyReqVO;
import com.hngtrust.iir.company.controller.vo.ListCompanyRespVO;
import com.hngtrust.iir.company.controller.vo.ListDealingRespVO;
import com.hngtrust.iir.company.controller.vo.ListHolderReqVO;
import com.hngtrust.iir.company.controller.vo.ListHolderRespVO;
import com.hngtrust.iir.company.controller.vo.ListInvestRespVO;
import com.hngtrust.iir.company.controller.vo.ListManagementRespVO;
import com.hngtrust.iir.company.controller.vo.ListOperationRespVO;
import com.hngtrust.iir.company.controller.vo.ListPortraitRespVO;
import com.hngtrust.iir.company.controller.vo.ListTagRespVO;
import com.hngtrust.iir.company.controller.vo.ViewCompanyReqVO;
import com.hngtrust.iir.company.controller.vo.ViewCompanyRespVO;
import com.hngtrust.iir.company.dto.ListChangeReqDTO;
import com.hngtrust.iir.company.dto.ListSubsidiaryDTO;
import com.hngtrust.iir.company.service.CompService;
import com.hngtrust.iir.dto.ReqDTO;
import com.hngtrust.iir.exception.IirErrorType;
import com.hngtrust.iir.exception.IirException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 公司操作
 * @author Chentianyong
 * @date 2021-03-22 10:59
 */
@Slf4j
@Api(tags = "公司操作")
@RestController
@RequestMapping("/company")
public class CompanyController {
    
    @Autowired
    private CompService compService;
    
    /**
     * 公司列表
     */
    @ApiOperation(value = "公司列表", notes = "公司列表")
    @PostMapping("/list-company")
    public ResponseInfo<PageResult<ListCompanyRespVO>> listCompany(
            @ApiParam(value = "公司列表") @Valid @RequestBody ReqDTO<ListCompanyReqVO> req) {
        log.info("CompanyController.listCompany start...");
    
        PageResult<ListCompanyRespVO> pageResult = compService.queryComp(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 公司列表(不分页)
     */
    @ApiOperation(value = "公司列表(不分页)", notes = "公司列表(不分页)")
    @PostMapping("/list-companyNoPage")
    public ResponseInfo<List<ListCompanyRespVO>> listCompanyNoPage(
            @ApiParam(value = "公司列表(不分页)") @Valid @RequestBody ListCompanyReqVO req) {
        log.info("CompanyController.listCompanyNoPage start...");
        
        List<ListCompanyRespVO> pageResult = compService.queryCompNoPage(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 公司详情
     */
    @ApiOperation(value = "公司详情", notes = "公司详情")
    @PostMapping("/view-company")
    public ResponseInfo<ViewCompanyRespVO> viewCompany(
            @ApiParam(value = "公司详情") @Valid @RequestBody ViewCompanyReqVO req) {
        log.info("CompanyController.viewCompany start...");
        
        if(!(req.getId() > 0L)){
            throw new IirException(IirErrorType.INTFACE_PARAMS_ERROR,"ID");
        }
        ViewCompanyRespVO resp = compService.viewCompany(req);
        
        ResponseInfo<ViewCompanyRespVO> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }
    
    /**
     * 公司股东列表
     */
    @ApiOperation(value = "公司股东列表", notes = "公司股东列表")
    @PostMapping("/list-holder")
    public ResponseInfo<PageResult<ListHolderRespVO>> listHolder(
            @ApiParam(value = "公司股东列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("CompanyController.listHolder start...");
    
        PageResult<ListHolderRespVO> pageResult = compService.listHolder(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 公司管理成员列表
     */
    @ApiOperation(value = "公司管理成员列表", notes = "公司管理成员列表")
    @PostMapping("/list-management")
    public ResponseInfo<PageResult<ListManagementRespVO>> listManagement(
            @ApiParam(value = "公司管理成员列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("CompanyController.listManagement start...");
    
        PageResult<ListManagementRespVO> pageResult = compService.listManagement(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 公司管理成员职务列表
     */
    @ApiOperation(value = "公司管理成员职务列表", notes = "公司管理成员职务列表")
    @PostMapping("/list-management-post")
    public ResponseInfo<List<AiCompanyReqVO>> listManagementPost(
            @ApiParam(value = "公司管理成员职务列表") @Valid @RequestBody ListHolderReqVO req) {
        log.info("CompanyController.listManagementPost start...");
    
        List<AiCompanyReqVO> resp = compService.listManagementPost(req);
    
        ResponseInfo<List<AiCompanyReqVO>> data = new ResponseInfo<>();
        data.setData(resp);
        return data;
    }
    
    /**
     * 公司对外投资列表
     */
    @ApiOperation(value = "公司对外投资列表", notes = "公司对外投资列表")
    @PostMapping("/list-invest")
    public ResponseInfo<PageResult<ListInvestRespVO>> listInvest(
            @ApiParam(value = "公司对外投资列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("CompanyController.listInvest start...");
    
        PageResult<ListInvestRespVO> pageResult = compService.listInvest(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 子公司列表
     */
    @ApiOperation(value = "子公司列表", notes = "子公司列表")
    @PostMapping("/list-subsidiary")
    public ResponseInfo<PageResult<ListSubsidiaryDTO>> listSubsidiary(
            @ApiParam(value = "子公司列表") @Valid @RequestBody ReqDTO<ListHolderReqVO> req) {
        log.info("CompanyController.listSubsidiary start...");
    
        PageResult<ListSubsidiaryDTO> pageResult = compService.listSubsidiary(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 公司发展沿革列表
     */
    @ApiOperation(value = "公司发展沿革列表", notes = "公司发展沿革列表")
    @PostMapping("/list-change")
    public ResponseInfo<PageResult<ListChangeRespVO>> listChange(
            @ApiParam(value = "公司发展沿革列表") @Valid @RequestBody ReqDTO<ListChangeReqDTO> req) {
        log.info("CompanyController.listChange start...");
    
        PageResult<ListChangeRespVO> pageResult = compService.listChange(req);
        
        return new ResponseInfo(pageResult);
    }
    
    /**
     * 公司发展沿革
     */
    @ApiOperation(value = "公司发展沿革", notes = "公司发展沿革")
    @PostMapping("/comp-change")
    public ResponseInfo<List<CompChangeRespVO>> compChange(
            @ApiParam(value = "公司发展沿革") @Valid @RequestBody ListHolderReqVO req) {
        log.info("CompanyController.compChange start...");
    
        List<CompChangeRespVO> pageResult = compService.compChange(req);
        
        ResponseInfo<List<CompChangeRespVO>> data = new ResponseInfo<>();
        data.setData(pageResult);
        return data;
    }
    
    /**
     * 公司画像
     */
    @ApiOperation(value = "公司画像", notes = "公司画像")
    @PostMapping("/comp-portrait")
    public ResponseInfo<List<ListPortraitRespVO>> compPortrait(
            @ApiParam(value = "公司画像") @Valid @RequestBody ListHolderReqVO req) {
        log.info("CompanyController.compPortrait start...");
    
        List<ListPortraitRespVO> pageResult = compService.compPortrait(req);
    
        ResponseInfo<List<ListPortraitRespVO>> data = new ResponseInfo<>();
        data.setData(pageResult);
        return data;
    }
    
    /**
     * 公司标签/轮廓
     */
    @ApiOperation(value = "公司标签/轮廓", notes = "公司标签/轮廓")
    @PostMapping("/comp-tag")
    public ResponseInfo<List<ListTagRespVO>> compTag(
            @ApiParam(value = "公司标签/轮廓") @Valid @RequestBody ListHolderReqVO req) {
        log.info("CompanyController.compTag start...");
    
        List<ListTagRespVO> pageResult = compService.compTag(req);
        
        ResponseInfo<List<ListTagRespVO>> data = new ResponseInfo<>();
        data.setData(pageResult);
        return data;
    }
    
    /**
     * 公司业务往来
     */
    @ApiOperation(value = "公司业务往来", notes = "公司业务往来")
    @PostMapping("/comp-dealing")
    public ResponseInfo<List<ListDealingRespVO>> compDealing(
            @ApiParam(value = "公司业务往来") @Valid @RequestBody ListHolderReqVO req) {
        log.info("CompanyController.compDealing start...");
    
        List<ListDealingRespVO> pageResult = compService.compDealing(req);
        
        ResponseInfo<List<ListDealingRespVO>> data = new ResponseInfo<>();
        data.setData(pageResult);
        return data;
    }
    
    /**
     * 公司经营情况
     */
    @ApiOperation(value = "公司经营情况", notes = "公司经营情况")
    @PostMapping("/comp-operation")
    public ResponseInfo<List<ListOperationRespVO>> compOperation(
            @ApiParam(value = "公司经营情况") @Valid @RequestBody ListHolderReqVO req) {
        log.info("CompanyController.compOperation start...");
    
        List<ListOperationRespVO> pageResult = compService.compOperation(req);
        
        ResponseInfo<List<ListOperationRespVO>> data = new ResponseInfo<>();
        data.setData(pageResult);
        return data;
    }
}
